package com.feihong.txgw.adapter.user;

import android.text.TextUtils;
import android.view.View;
import android.widget.TextView;

import com.adapter.base.BaseQuickAdapter;
import com.adapter.base.BaseViewHolder;
import com.feihong.txgw.R;
import com.feihong.txgw.model.bean.integral.IntegralBackEntity;

/**
 * @Author wangziheng
 * @ProjectName txgw_app
 * @ClassName IntegralDetailReAdapter
 * @package com.feihong.txgw.adapter.user
 * @data 2018/6/5 16:15
 * @Describe
 * @Change
 */
public class IntegralDetailReAdapter extends BaseQuickAdapter<IntegralBackEntity.DataBean.PageListBean,BaseViewHolder> {

    public IntegralDetailReAdapter(int layoutResId) {
        super(layoutResId);
        init();
    }

    @Override
    protected void convert(final BaseViewHolder helper, IntegralBackEntity.DataBean.PageListBean item) {
        helper.setText(R.id.integral_item_remark,item.getRemark());
        helper.setText(R.id.tv_content,item.getTitle());
        helper.setText(R.id.order_sn,item.getOrder_sn());
        helper.setText(R.id.add_time,item.getAdd_time());
        helper.setText(R.id.point_value,item.getPoint_value());
        helper.setText(R.id.use_point_tv,item.getUse_point());
        if (!TextUtils.isEmpty(item.getPoint_value()) && item.getPoint_value().contains("+")) {
            helper.setTextColor(R.id.point_value,mContext.getResources().getColor(R.color.appRed));
        } else if (!TextUtils.isEmpty(item.getPoint_value()) && item.getPoint_value().contains("-")) {
            helper.setTextColor(R.id.point_value,mContext.getResources().getColor(R.color.black_text));
        }
        helper.itemView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                TextView remarkView = helper.getView(R.id.integral_item_remark);
                if (remarkView.getVisibility() == View.VISIBLE) {
                    remarkView.setVisibility(View.GONE);
                } else {
                    remarkView.setVisibility(View.VISIBLE);
                }
            }
        });
    }

    private void init() {
        setEnableLoadMore(false);
        loadMoreEnd(false);
        openLoadAnimation();
        isFirstOnly(false);
    }

}
